﻿@model Orchard.ContentFields.ViewModels.DisplayLinkFieldViewModel
@using Orchard.ContentManagement.Metadata.Models
@using Orchard.ContentFields.Settings;

@{
    var settings = Model.PartFieldDefinition.Settings.ToObject<LinkFieldSettings>();
    string name = Model.PartFieldDefinition.DisplayName();
    string text = Model.Field.Text;
    switch (settings.LinkTextMode)
    {
        case LinkTextMode.Static:
            if (!String.IsNullOrWhiteSpace(settings.DefaultText))
            {
                text = settings.DefaultText;
            }
            else
            {
                text = Model.Field.Url;
            }
            break;
        case LinkTextMode.Url:
            text = Model.Field.Url;
            break;
        case LinkTextMode.Optional:
            if (String.IsNullOrWhiteSpace(text))
            {
                text = Model.Field.Url;
            }
            break;
    }
}
<div>
    @Model.PartFieldDefinition.DisplayName():
    <a href="@Model.Field.Url">@text</a>
</div>